// SPDX-License-Identifier: GPL-2.0
/*
 * TEMPORARY MAPPING: MMIO
 *
 * (C) 2024.05.01 BuddyZhang1 <buddy.zhang@aliyun.com>
 */
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/io.h>

/* MMIO BY CALLER */
#define MMIO_BASE	0xfebf1000
#define MMIO_SIZE	0x1000

static int __init BiscuitOS_init(void)
{
	void *mem;

	/* TEMPORARY MAPPING MMIO */
	mem = ioremap(MMIO_BASE, MMIO_SIZE);
	if (!mem) {
		printk("ERROR: MMIO FAILED\n");
		return -ENOMEM;
	}

	/* ACCESS */
	sprintf((char *)mem, "Hello BiscuitOS");
	printk("%s\n", (char *)mem);

	/* TEMPORARY UNMAPPING MMIO */
	iounmap(mem);

	return 0;
}

static void __exit BiscuitOS_exit(void) { }

module_init(BiscuitOS_init);
module_exit(BiscuitOS_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("BiscuitOS <buddy.zhang@aliyun.com>");
MODULE_DESCRIPTION("Linux Dream Motion on BiscuitOS");
